package com.linys.scala.qf.day03.matchdemo

object MatchArrayTupleList {
  def main(args: Array[String]): Unit = {
    // 匹配数组
    val arr = Array(2,5,7,8)

    arr match {
      case Array(3, a, b, c) => println("case 1")
      case Array(2, _*) => println("case 2")
      case Array(_*) => println("Nothing...")
    }

    // 匹配元组
   val tup = (2,3,5,8)
   tup match {
     case (3, a,b,c) => println("case 1")
     case (_, x,y,z) => println("case 2")
     case _ => println("Nothing...")
   }

    // 匹配集合
    val list = List(2,3,5,6,7)
    list match {
      case 1::Nil => println("case 1")
      case a::b::c::d::Nil => println("case 2")
      case 2::List(x,y,z,k) => println("case 3")
      case _ => println("Nothing...")
    }


  }
}
